<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <video id="video" src="https://example.com/video.mp4" controls></video>
    <script>
        // 监听页面可见性变化事件.tab页切换，视频暂停播放、停止轮询等操作
        document.addEventListener('visibilitychange', () => {
            document.visibilityState === 'hidden'
                ? video.pause()
                : video.play();
        });

    </script>
</body>
</html>